home *** CD-ROM | disk | FTP | other *** search
- /* $Id: SFSconfig.cpp 1.2 1999/10/14 17:41:28 helios Exp $
-
- Sets and queries SmartFilesystem parameters
- */
-
- #include <dos/dos.h>
- #include <dos/dosextens.h>
- #include <utility/tagitem.h>
- #include "fs/packets.h"
- #include "fs/query.h"
-
- #include <pragmas/dos_pragmas.h>
-
- const char *version_str = "\0$VER: SFSconfig 1.2 (14.10.1999) (W) by Martin Steigerwald\r\n";
-
- #define TEMPLATE "DEVICE/A,LINES/N,READAHEAD=READAHEADSIZE/N,MAXNAMELENGTH=MAXNAME/N,ACTIVITYFLUSH/N,INACTIVITYFLUSH/N,COPYBACK/S,NOCOPYBACK/S"
-
- main()
- {
- struct RDArgs *rdargs=NULL;
-
- struct {
- char *device;
- ULONG *lines;
- ULONG *readahead;
- ULONG *maxname;
- ULONG *activityflush;
- ULONG *inactivityflush;
- ULONG copyback;
- ULONG nocopyback;
- } args={NULL};
-
- rdargs = ReadArgs(TEMPLATE, (LONG *)&args, NULL);
-
- if (rdargs == NULL) {
- PrintFault(IoErr(), "SFSconfig");
- return RETURN_ERROR;
- }
- else {
- if (args.copyback!=0 && args.nocopyback!=0) {
- Printf("SFSConfig: Make a decision. Copyback or not? ;-)\n");
- FreeArgs(rdargs);
- return(5L);
- }
-
- struct DosList *dl;
- struct MsgPort *port;
- UBYTE *devname=args.device;
-
- // remove colon from devicename
- while(*devname!=0) {
- if(*devname==':') {
- *devname=0;
- break;
- }
- devname++
- }
-
- dl=LockDosList(LDF_DEVICES|LDF_READ);
-
- if ((dl = FindDosEntry(dl, args.device, LDF_DEVICES))!=0) {
- LONG errorcode;
-
- port=dl->dol_Task;
-
- struct TagItem vtags[]={
- ASQ_VERSION, 0
- };
-
- if ((errorcode = DoPkt(port, ACTION_SFS_QUERY, (LONG)&vtags, 0, 0, 0, 0))!=DOSFALSE) {
- LONG version, revision;
-
- version=vtags[0].ti_Data / 65536;
- revision=vtags[0].ti_Data - (version * 65536);
-
- // set filename length?
- if (args.maxname != 0) {
- Printf("Setting maximum filename length ...\n");
- struct TagItem stags[]={
- ASS_MAX_NAME_LENGTH, *args.maxname,
- TAG_DONE
- };
- if ((errorcode = DoPkt(port, ACTION_SFS_SET, (LONG)&stags, 0, 0, 0, 0))==DOSFALSE) {
- PrintFault(IoErr(), "SFSConfig");
- }
- }
-
- // set maximum activity flush time?
- if (args.activityflush != 0) {
- Printf("Setting activity flush timeout ...\n");
- struct TagItem stags[]={
- ASS_ACTIVITY_FLUSH_TIMEOUT, *args.activityflush,
- TAG_DONE
- };
- if ((errorcode = DoPkt(port, ACTION_SFS_SET, (LONG)&stags, 0, 0, 0, 0))==DOSFALSE) {
- PrintFault(IoErr(), "SFSconfig");
- }
- }
-
- // set maximum activity flush time?
- if (args.inactivityflush != 0) {
- Printf("Setting inactivity flush timeout ...\n");
- struct TagItem stags[]={
- ASS_INACTIVITY_FLUSH_TIMEOUT, *args.inactivityflush,
- TAG_DONE
- };
- if ((errorcode = DoPkt(port, ACTION_SFS_SET, (LONG)&stags, 0, 0, 0, 0))==DOSFALSE) {
- PrintFault(IoErr(), "SFSConfig");
- }
- }
-
-
- // set the cache?
- if (args.lines != 0 || args.readahead !=0 || args.copyback != 0 || args.nocopyback !=0) {
- Printf("Setting cache ...\n");
-
- struct TagItem ctags[]={
- ASQ_CACHE_LINES, 0,
- ASQ_CACHE_READAHEADSIZE, 0,
- ASQ_CACHE_MODE, 0,
- TAG_DONE
- };
-
- if ((errorcode = DoPkt(port, ACTION_SFS_QUERY, (LONG)&ctags, 0, 0, 0, 0))!=DOSFALSE) {
- ULONG lines = ctags[0].ti_Data;
- ULONG readahead = ctags[1].ti_Data;
- ULONG copyback = ctags[2].ti_Data;
-
- if (args.lines!=0) {
- lines = *args.lines;
- }
- if (args.readahead!=0) {
- readahead = *args.readahead;
- }
- if (args.copyback!=0) {
- copyback=1
- }
- if (args.nocopyback!=0) {
- copyback=0
- }
-
- if ((errorcode = DoPkt(port, ACTION_SET_CACHE, lines, readahead, copyback, 0, 0))==DOSFALSE) {
- PrintFault(IoErr(), "SFSconfig");
- }
-
- }
- else {
- Printf("SFSConfig: Could not query cache parameters!\n");
- PrintFault(IoErr(), "SFSconfig");
- } // query cache parameters
- } // set the cache?
-
- // show all informations
- struct TagItem qtags[]={
- ASQ_IS_CASESENSITIVE, 0,
- ASQ_HAS_RECYCLED, 0,
- ASQ_CACHE_LINES, 0,
- ASQ_CACHE_READAHEADSIZE, 0,
- ASQ_CACHE_MODE, 0,
- TAG_DONE
- };
-
- Printf("Devicename: %s:\n", args.device);
-
- Printf("SFS version: %ld.%ld\n", version, revision);
-
- if ((errorcode = DoPkt(port, ACTION_SFS_QUERY, (LONG)&qtags, 0, 0, 0, 0))!=DOSFALSE) {
-
- Printf("Cache: %ld lines * %ld bytes readahead size = %ld bytes.\n",
- qtags[2].ti_Data, qtags[3].ti_Data, qtags[2].ti_Data * qtags[3].ti_Data);
-
- Printf(" Copyback mode");
-
- if (qtags[4].ti_Data==0) {
- Printf(" disabled.\n");
- }
- else {
- Printf(" enabled.\n");
- }
-
- Printf("Fixed options: ");
-
- if (qtags[0].ti_Data!=0) {
- Printf("(case sensitive) ");
- }
- else {
- Printf("(not case-sensitive) ");
- }
-
- if (qtags[1].ti_Data!=0) {
- Printf("(recycled)");
- }
- else {
- Printf("(no recycled)");
- }
-
- Printf("\n");
- }
- else {
- Printf("SFSconfig: Second SFSQuery failed!\n");
- PrintFault(IoErr(), "SFSconfig");
- }
- }
- else {
- Printf("SFSconfig: SFSQUERY failed. Maybe no SFS device?\n");
- PrintFault(IoErr(), "SFSconfig");
- }
- }
- else {
- Printf("Couldn't find device: '%s:'\n", args.device);
- }
- UnLockDosList(LDF_DEVICES|LDF_READ);
-
- FreeArgs(rdargs);
- } // ReadArgs
- }
-
-